package com.epichust.bootuqc.controller;

import com.epichust.bootuqc.model.bo.ReturnBO;
import com.epichust.bootuqc.model.entity.Uqcm5ChkMould;
import com.epichust.bootuqc.service.IUqcm5ChkMouldService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ：ziyang
 * @date ：Created in 2021/1/18 19:49
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("api/chkMould")
public class Uqcm5ChkMouldController {

    @Autowired
    private IUqcm5ChkMouldService iUqcm5ChkMouldService;

    @RequestMapping(value = "/getAll", method = {RequestMethod.POST})
    public String getAllUqcm5ChkMould(@RequestBody Map<String,Object> map){
        try{
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
            ReturnBO bo = new ReturnBO();
            List<Uqcm5ChkMould> list = iUqcm5ChkMouldService.getAllUqcm5ChkMould(map);
            bo.setState(0);
            bo.setObject(list);
            return gson.toJson(bo);
        }catch (Exception e){
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            bo.setState(1);
            bo.setObject("查询失败："+e.getMessage());
            return gson.toJson(bo);
        }
    }
}
